﻿using System;
using System.Web;

namespace Basmus.Web
{
    internal class FakeHttpContext : HttpContextBase
    {
        public FakeHttpContext(string applicationPath)
        {
            _req = new FakeHttpRequest(applicationPath);
        }

        HttpRequestBase _req;
        public override HttpRequestBase Request
        {
            get
            {
                return _req;
            }
        }

        HttpResponseBase _resp = new FakeHttpResponse();
        public override HttpResponseBase Response
        {
            get
            {
                return _resp;
            }
        }

        class FakeHttpRequest : HttpRequestBase
        {
            public FakeHttpRequest(string appPath)
            {
                if (appPath == null)
                    throw new ArgumentNullException();

                _appPath = appPath;
            }

            string _appPath;
            public override string ApplicationPath
            {
                get
                {
                    return _appPath;
                }
            }
        }

        class FakeHttpResponse : HttpResponseBase
        {
            public override string ApplyAppPathModifier(string virtualPath)
            {
                return virtualPath;
            }
        }
    }
}
